package com.hunan.api.catv.service.impl.umeng;

import com.alibaba.ocean.rawsdk.ApiExecutor;
import com.alibaba.ocean.rawsdk.client.exception.OceanException;
import com.hunan.api.catv.utils.GsonUtils;
import com.umeng.uapp.param.UmengUappGetAllAppDataParam;
import com.umeng.uapp.param.UmengUappGetAllAppDataResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

@Service
public class UmengService {

    public static Logger log = LoggerFactory.getLogger(UmengService.class);

    public String umengUappGetAllAppData(String apiKey, String apiSecurity, String host) {
        ApiExecutor apiExecutor = new ApiExecutor(apiKey, apiSecurity);
        apiExecutor.setServerHost(host);
        UmengUappGetAllAppDataParam param = new UmengUappGetAllAppDataParam();
        try {
            UmengUappGetAllAppDataResult result = apiExecutor.execute(param);
            return GsonUtils.toJson(result);
        } catch (OceanException e) {
            log.error("[友盟GetAllAppData-Error:]", e);
        }
        return null;
    }

}
